
function XMLHttpRequest() {
    this.config = {};
}

XMLHttpRequest.prototype = {
    open(method, url, isAsync) {
        this.config.method = method;
        this.config.url = url;
        this.isAsync = isAsync;
    },
  send(data) {
      let reqParam = {
        url: this.config.url,
        method: this.config.method || 'post',
        dataType: 'text',
        responseType: this.responseType || 'text',
        data: data || "",
        success: (resp) => {
          this.status = resp.statusCode;
          this.readystate = 4;
          this.responseText = resp.data;
          this.onload && this.onload();
        },
        fail: (err) => {
          this.status = 9001;
          this.readystate = 4;
          this.responseText = err.message;
          this.onerror && this.onerror();
        }
      }

      wx.request(reqParam);
    }
}

module.exports = XMLHttpRequest;